home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Missions Cog Script
- #
- # POW_SINGLE_FLASHBOMB_M.COG
- #
- # POWERUP Script - single Flash Bomb
- #
- # [YB & CYW] + [RF]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
-
- symbols
-
- template explode=+flash_exp local
-
- thing powerup local
- thing player local
- thing sender local
-
- int bin=14 local
- sound pickupsnd=thrmlpu2.wav local
- sound respawnsnd=Activate01.wav local
- flex amount local
-
- #for the projectiles
- vector dir local
-
- int autosel=-1 local
- int bin_contents=0 local
- int autopickup=0 local
-
- message created
- message damaged
- message touched
- message taken
- message respawn
- message timer
-
- end
-
- # ========================================================================================
-
- code
-
- created:
- SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
- Return;
-
- # ............................................................................................
-
- touched:
- if (GetWeaponBin(bin) == -1)
- return;
-
- player = GetSourceRef();
- if (GetThingType(player) == 10) // Can only be taken by players.
- {
- amount = GetInv(player, GetWeaponBin(bin));
-
- if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
- {
- TakeItem(GetSenderRef(), -1);
- call taken;
- }
- }
-
- Return;
-
- # ........................................................................................
-
- damaged:
- damage = GetParam (0);
- sender = GetSenderRef();
-
- // only take damage 33% of the time
- if(rand() < 0.33)
- return;
-
- // If it's already dead, don't allow any more damage.
- if (!GetThingUserData (sender))
- return;
-
- // see if this will cause the explosion
- if (GetThingUserData (sender) <= damage)
- {
- SetThingUserData (sender, 0);
-
- // timer for base explosion
- SetTimerEx ((Rand () * 0.5), sender, 1, 0);
- }
- else
- {
- SetThingUserData (sender, GetThingUserData (sender) - damage);
- }
-
- ReturnEx (0);
- return;
-
- # ........................................................................................
-
- taken:
- if (GetWeaponBin(bin) == -1)
- return;
-
- player = GetSourceRef();
- powerup = GetSenderRef();
-
- // // If the object has been destroyed, don't award it to the player.
- // if (!GetThingUserData (powerup))
- // return;
-
- // Print("Thermal Detonator");
- jkPrintUNIString(player, 211);
-
- // Do effects.
- PlaySoundLocal(pickupsnd, 1, 0, 0);
- AddDynamicTint(player, 0.0, 0.0, 0.2);
-
- // store the old bin contents
- bin_contents = GetInv(player, GetWeaponBin(bin));
-
- // Increment powerup amount.
- ChangeInv(player, GetWeaponBin(bin), 1.0);
-
- // Check for Auto Pickup
- autopickup = GetAutoPickup();
- if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
- {
- if(!bin_contents)
- {
- if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
- {
- if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
- {
- SelectWeapon(player, GetWeaponBin(bin));
- Return;
- }
- }
- }
- }
-
- // Check for Auto Reload
- if(GetAutoReload() & 1)
- {
- if(!bin_contents)
- {
- if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
- {
- // Try to autoselect and see if the best weapon is the TD
- autosel = AutoSelectWeapon(player, 2);
- if(autosel == bin) SelectWeapon(player, GetWeaponBin(bin));
- }
- }
- }
-
- return;
-
- # ........................................................................................
-
- respawn:
- SetThingUserData(GetSenderRef(), 30); // set the initial user data (i.e. "health")
- PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
-
- return;
-
- # ........................................................................................
-
- timer:
- sender = GetSenderId ();
-
- // cause the base explosion
- powerup = CreateThingNR(explode, sender);
-
- // Since the user data is 0, the player won't actually be awarded this powerup.
- TakeItem (sender, -1);
- return;
-
- end
-